package deepr.src;

import lombok.Data;

import java.util.HashMap;
import java.util.HashSet;

@Data
public class ParseResult {

    HashMap<String, Object> pgFilterParams = new HashMap<>();
    HashMap<String, Object> neo4jFilterParams = new HashMap<>();

    HashMap<String, String> pgFilter = new HashMap<>();
    HashMap<String, String> neo4jFilter = new HashMap<>();

    StringBuilder pgWithStr = new StringBuilder();
    String pgInfoStr;
    StringBuilder pgReturnStr = new StringBuilder();

    StringBuilder neo4jWithStr = new StringBuilder();

    StringBuilder neo4jWithObjStr = new StringBuilder();

    StringBuilder neo4jBelongStr = new StringBuilder();

    StringBuilder neo4jMatchStr = new StringBuilder();

    StringBuilder neo4jStr = new StringBuilder();

    HashSet<String> alreadyMatched = new HashSet<>();

    String neo4jRelObj = "";

    public ParseResult() {

    }

    public void appendAlreadyMatched(String obj) {
        alreadyMatched.add(obj);
    }

    public void setNeo4jBelongStr(StringBuilder sb) {
        this.neo4jBelongStr = sb;
    }

    public boolean matchedContains(String obj) {
        return alreadyMatched.contains(obj);
    }

    public void appendNeo4jWithStr(String with) {
        if (neo4jWithStr.length() > 0)
            neo4jWithStr.append(",");
        neo4jWithStr.append(with);
    }

    public void appendNeo4jMatchStr(String with) {
        if (neo4jMatchStr.length() > 0)
            neo4jMatchStr.append(",");
        neo4jMatchStr.append(with);
    }

    public void appendNeo4jWithObjStr(String obj) {
        if (neo4jWithObjStr.length() > 0)
            neo4jWithObjStr.append(",");
        neo4jWithObjStr.append(obj);
    }

    public void putNeo4jFilter(String Object, String str) {
        neo4jFilter.put(Object, str);
    }

    public void putNeo4jFilterParams(String key, Object value) {
        neo4jFilterParams.put(key, value);
    }


    public String getPgParseStr() {
        return "WITH " + pgWithStr + "SELECT " + pgReturnStr;
    }

    public void appendPgStr(String withStr, String selectStr) {
        if (pgWithStr.length() > 0) {
            pgWithStr.append(",");
            pgReturnStr.append(",");
        }
        pgWithStr.append(withStr);
        pgReturnStr.append(selectStr);
    }

    public void setPgInfoStr(String str) {
        this.pgInfoStr = str;
    }

    public void putPgFilter(String Object, String str) {
        pgFilter.put(Object, str);
    }

    public void putPgFilterParams(String key, Object value) {
        pgFilterParams.put(key, value);
    }


}
